package com.gzz.orchid.context.domain.rbac.entity;

import com.gzz.orchid.context.infrastructure.definition.Status;
import com.gzz.orchid.context.infrastructure.persistence.entity.sys.SysOrganizationPo;
import lombok.Data;

/**
 * @author higmd
 */
@Data
public class OrganizationDo {
    private Long id;
    /**
     * 父级模块 id parent_id
     */
    private Long parentId;
    /**
     * 机构编码 code
     */
    private String code;
    /**
     * 机构名称 name
     */
    private String name;
    /**
     * 机构描述 description
     */
    private String description;
    /**
     * 机构状态 status
     */
    private Status status;

    /**
     * 转换
     */
    public static OrganizationDo convertFrom(SysOrganizationPo po) {
        OrganizationDo mdo = new OrganizationDo();
        mdo.setId(po.getId());
        mdo.setParentId(po.getParentId());
        mdo.setCode(po.getCode());
        mdo.setName(po.getName());
        mdo.setDescription(po.getDescription());
        mdo.setStatus(Status.parse(po.getStatus()));
        return mdo;
    }
}
